
function pickUpPos(viewer, Cesium) {
    this.viewer = viewer;
    this.Cesium = Cesium;
    this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
}

pickUpPos.prototype.getPos=function (callback) {
    var that=this;
    let viewer = this.viewer;
    let Cesium = this.Cesium;
    viewer.scene.globe.depthTestAgainstTerrain = true;
    //得到当前三维场景的椭球体
    var ellipsoid = viewer.scene.globe.ellipsoid;
    // 定义当前场景的画布元素的事件处理
    var res = new Object();
    //设置鼠标移动事件的处理函数，这里负责监听x,y坐标值变化
    that.handler.setInputAction(function(movement) {
        // var ray = viewer.scene.camera.getPickRay(movement.position);
        // var cartesian = viewer.scene.globe.pick(ray, viewer.scene);
        var cartesian = viewer.scene.pickPosition(movement.position);
        if (cartesian) {
            //将笛卡尔坐标转换为地理坐标
            var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
            //将弧度转为度的十进制度表示
            var longitudeString = Cesium.Math.toDegrees(cartographic.longitude);
            var latitudeString = Cesium.Math.toDegrees(cartographic.latitude);
           // var elev = viewer.scene.globe.getHeight(cartographic);
            res.longitude = longitudeString; //经度
            res.latitude = latitudeString; //纬度
            res.height = viewer.scene.sampleHeight(cartographic); //高程
            callback(res);
        }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK );
}

pickUpPos.prototype.clear=function () {
    this.handler.removeInputAction(this.Cesium.ScreenSpaceEventType.LEFT_CLICK);
}

export default pickUpPos;